package org.eddycar.jproyeddycar.contrato.vistas;

import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import org.eddycar.jproyeddycar.negocio.Control;
import org.eddycar.jproyeddycar.contrato.dao.DaoContrato;
import org.eddycar.jproyeddycar.contrato.dao.DaoContratoEditable;
import org.eddycar.jproyeddycar.contrato.dao.DaoDocumento;
import org.eddycar.jproyeddycar.contrato.dao.DaoSolicitudFinanciamiento;
import org.eddycar.jproyeddycar.contrato.modelo.ContratoCompraVenta;
import org.eddycar.jproyeddycar.contrato.modelo.ContratoEditable;
import org.eddycar.jproyeddycar.contrato.modelo.DocumentoPrivado;
import org.eddycar.jproyeddycar.contrato.modelo.SolicitudFinanciamiento;
import org.jdesktop.observablecollections.ObservableList;

public class VistaBuscarContratos extends javax.swing.JDialog {

    String cedula = "";
    int posi = 5;

    public VistaBuscarContratos() {
        super(new javax.swing.JFrame(), true);
        initComponents();
        setLocationRelativeTo(this);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        imagen = new org.edisoncor.gui.panel.PanelImage();
        btnMostrar = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        panelRound1 = new org.edisoncor.gui.panel.PanelRound();
        jLabel1 = new javax.swing.JLabel();
        txtCedula = new javax.swing.JTextField();
        btnBuscar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        panelRect1 = new org.edisoncor.gui.panel.PanelRect();
        tabbedPaneVertical1 = new org.edisoncor.gui.tabbedPane.TabbedPaneVertical();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblSoli = new javax.swing.JTable();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblCV = new javax.swing.JTable();
        jScrollPane4 = new javax.swing.JScrollPane();
        tblDPE = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblDocumento = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(VistaBuscarContratos.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setForeground(resourceMap.getColor("Form.foreground")); // NOI18N
        setName("Form"); // NOI18N
        setResizable(false);

        imagen.setIcon(resourceMap.getIcon("imagen.icon")); // NOI18N
        imagen.setName("imagen"); // NOI18N

        btnMostrar.setText(resourceMap.getString("btnMostrar.text")); // NOI18N
        btnMostrar.setName("btnMostrar"); // NOI18N
        btnMostrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMostrarActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Courier 10 Pitch", 1, 24));
        jLabel2.setForeground(resourceMap.getColor("jLabel2.foreground")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        panelRound1.setName("panelRound1"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        txtCedula.setText(resourceMap.getString("txtCedula.text")); // NOI18N
        txtCedula.setName("txtCedula"); // NOI18N
        txtCedula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCedulaActionPerformed(evt);
            }
        });

        btnBuscar.setText(resourceMap.getString("btnBuscar.text")); // NOI18N
        btnBuscar.setName("btnBuscar"); // NOI18N
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelRound1Layout = new javax.swing.GroupLayout(panelRound1);
        panelRound1.setLayout(panelRound1Layout);
        panelRound1Layout.setHorizontalGroup(
            panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelRound1Layout.createSequentialGroup()
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(78, 78, 78)
                        .addComponent(btnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelRound1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(71, Short.MAX_VALUE))
        );
        panelRound1Layout.setVerticalGroup(
            panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRound1Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(panelRound1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBuscar)
                    .addComponent(jButton1))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        panelRect1.setName("panelRect1"); // NOI18N

        tabbedPaneVertical1.setName("tabbedPaneVertical1"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        tblSoli.setName("tblSoli"); // NOI18N

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${listaObservable}");
        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, tblSoli);
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
        columnBinding.setColumnName("Id");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${fechaContrato}"));
        columnBinding.setColumnName("Fecha Contrato");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${garanteCedula}"));
        columnBinding.setColumnName("Garante Cedula");
        columnBinding.setColumnClass(String.class);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${vehiculoPlaca}"));
        columnBinding.setColumnName("Vehiculo Placa");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        tblSoli.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblSoliMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tblSoli);
        tblSoli.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblSoli.columnModel.title0")); // NOI18N
        tblSoli.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblSoli.columnModel.title1")); // NOI18N
        tblSoli.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tblSoli.columnModel.title2")); // NOI18N
        tblSoli.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("tblSoli.columnModel.title3")); // NOI18N

        tabbedPaneVertical1.addTab(resourceMap.getString("jScrollPane3.TabConstraints.tabTitle"), jScrollPane3); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        tblCV.setName("tblCV"); // NOI18N

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${listaObservable2}");
        jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, tblCV);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
        columnBinding.setColumnName("Id");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${fechaContrato}"));
        columnBinding.setColumnName("Fecha Contrato");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${tipoContrato}"));
        columnBinding.setColumnName("Tipo Contrato");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${vehiculoPlaca}"));
        columnBinding.setColumnName("Vehiculo Placa");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        tblCV.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblCVMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tblCV);
        tblCV.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblCV.columnModel.title1")); // NOI18N
        tblCV.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblCV.columnModel.title0")); // NOI18N
        tblCV.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tblCV.columnModel.title2")); // NOI18N
        tblCV.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("jTable1.columnModel.title4")); // NOI18N

        tabbedPaneVertical1.addTab(resourceMap.getString("jScrollPane1.TabConstraints.tabTitle"), jScrollPane1); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        tblDPE.setName("tblDPE"); // NOI18N

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${listaObservable5}");
        jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, tblDPE);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${cedula}"));
        columnBinding.setColumnName("Cedula");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${codigo}"));
        columnBinding.setColumnName("Codigo");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nombres}"));
        columnBinding.setColumnName("Nombres");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        tblDPE.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblDPEMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(tblDPE);
        tblDPE.getColumnModel().getColumn(0).setResizable(false);
        tblDPE.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblDPE.columnModel.title0")); // NOI18N
        tblDPE.getColumnModel().getColumn(1).setResizable(false);
        tblDPE.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblDPE.columnModel.title1")); // NOI18N
        tblDPE.getColumnModel().getColumn(2).setResizable(false);
        tblDPE.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tblDPE.columnModel.title2")); // NOI18N

        tabbedPaneVertical1.addTab(resourceMap.getString("jScrollPane4.TabConstraints.tabTitle"), jScrollPane4); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        tblDocumento.setName("tblDocumento"); // NOI18N

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${listaObservable4}");
        jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, tblDocumento);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
        columnBinding.setColumnName("Id");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${fecha}"));
        columnBinding.setColumnName("Fecha");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${plaVehiculo}"));
        columnBinding.setColumnName("Pla Vehiculo");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${plaVehiculo2}"));
        columnBinding.setColumnName("Pla Vehiculo2");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        tblDocumento.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblDocumentoMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tblDocumento);
        tblDocumento.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tblDocumento.columnModel.title0")); // NOI18N
        tblDocumento.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tblDocumento.columnModel.title1")); // NOI18N
        tblDocumento.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tblDocumento.columnModel.title2")); // NOI18N
        tblDocumento.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("tblDocumento.columnModel.title3")); // NOI18N

        tabbedPaneVertical1.addTab(resourceMap.getString("jScrollPane2.TabConstraints.tabTitle"), jScrollPane2); // NOI18N

        javax.swing.GroupLayout panelRect1Layout = new javax.swing.GroupLayout(panelRect1);
        panelRect1.setLayout(panelRect1Layout);
        panelRect1Layout.setHorizontalGroup(
            panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRect1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabbedPaneVertical1, javax.swing.GroupLayout.PREFERRED_SIZE, 723, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelRect1Layout.setVerticalGroup(
            panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRect1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabbedPaneVertical1, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
                .addContainerGap())
        );

        jLabel3.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel3.setForeground(resourceMap.getColor("jLabel4.foreground")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel4.setForeground(resourceMap.getColor("jLabel4.foreground")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        javax.swing.GroupLayout imagenLayout = new javax.swing.GroupLayout(imagen);
        imagen.setLayout(imagenLayout);
        imagenLayout.setHorizontalGroup(
            imagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(imagenLayout.createSequentialGroup()
                .addGroup(imagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(imagenLayout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(imagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(imagenLayout.createSequentialGroup()
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(42, 42, 42)
                                .addComponent(jLabel2))
                            .addGroup(imagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(panelRound1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(panelRect1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(imagenLayout.createSequentialGroup()
                        .addGap(276, 276, 276)
                        .addComponent(btnMostrar)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        imagenLayout.setVerticalGroup(
            imagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(imagenLayout.createSequentialGroup()
                .addGroup(imagenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(imagenLayout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(jLabel2))
                    .addGroup(imagenLayout.createSequentialGroup()
                        .addGap(52, 52, 52)
                        .addComponent(jLabel3)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelRound1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel4)
                .addGap(2, 2, 2)
                .addComponent(panelRect1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnMostrar)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(imagen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(imagen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
        buscar();
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void tblDocumentoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblDocumentoMouseClicked
        cedula = tblDocumento.getValueAt(tblDocumento.getSelectedRow(), 0).toString();
        posi = 0;
    }//GEN-LAST:event_tblDocumentoMouseClicked

    private void tblSoliMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblSoliMouseClicked
        cedula = tblSoli.getValueAt(tblSoli.getSelectedRow(), 0).toString();
        posi = 1;
    }//GEN-LAST:event_tblSoliMouseClicked

    private void tblCVMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblCVMouseClicked
        cedula = tblCV.getValueAt(tblCV.getSelectedRow(), 0).toString();
        posi = 2;
    }//GEN-LAST:event_tblCVMouseClicked

    private void btnMostrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMostrarActionPerformed
        switch (posi) {
            case 0:
                new BuscarDocumento(cedula);
                dispose();
                break;
            case 1:
                new BuscarVistaSolicitudFinanciamiento(cedula);
                dispose();
                break;
            case 2:
                new BuscarVistaContratoCompraVenta(cedula);
                dispose();
                break;
            case 3:
                new BuscarContratoEditable(cedula);
                dispose();
                break;
            default:
                JOptionPane.showMessageDialog(this, "Seleccione un contrato", "Error", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_btnMostrarActionPerformed

    private void tblDPEMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblDPEMouseClicked
        cedula = tblSoli.getValueAt(tblDPE.getSelectedRow(), 0).toString();
        posi = 3;
    }//GEN-LAST:event_tblDPEMouseClicked

    private void txtCedulaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCedulaActionPerformed
        buscar();
    }//GEN-LAST:event_txtCedulaActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    txtCedula.setText("");
    listaObservable.clear();
    listaObservable2.clear();
    listaObservable4.clear();
    listaObservable5.clear();
    tblCV.repaint();
    tblDPE.repaint();
    tblDocumento.repaint();
    tblSoli.repaint();
}//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnMostrar;
    private org.edisoncor.gui.panel.PanelImage imagen;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private org.edisoncor.gui.panel.PanelRect panelRect1;
    private org.edisoncor.gui.panel.PanelRound panelRound1;
    private org.edisoncor.gui.tabbedPane.TabbedPaneVertical tabbedPaneVertical1;
    private javax.swing.JTable tblCV;
    private javax.swing.JTable tblDPE;
    private javax.swing.JTable tblDocumento;
    private javax.swing.JTable tblSoli;
    private javax.swing.JTextField txtCedula;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
    private List<SolicitudFinanciamiento> listaSolicitud = new ArrayList<SolicitudFinanciamiento>();

    public List<SolicitudFinanciamiento> getListaSolicitud() {
        return listaSolicitud;
    }

    public void setListaSolicitud(List<SolicitudFinanciamiento> listaSolicitud) {
        this.listaSolicitud = listaSolicitud;
    }
    private ObservableList<SolicitudFinanciamiento> listaObservable = org.jdesktop.observablecollections.ObservableCollections.observableList(listaSolicitud);

    public ObservableList<SolicitudFinanciamiento> getListaObservable() {
        return listaObservable;
    }

    public void setListaObservable(ObservableList<SolicitudFinanciamiento> listaObservable) {
        this.listaObservable = listaObservable;
    }
    private List<ContratoCompraVenta> listaContrato2 = new ArrayList<ContratoCompraVenta>();

    public List<ContratoCompraVenta> getListaContrato2() {
        return listaContrato2;
    }

    public void setListaContrato2(List<ContratoCompraVenta> listaContrato2) {
        this.listaContrato2 = listaContrato2;
    }
    private ObservableList<ContratoCompraVenta> listaObservable2 = org.jdesktop.observablecollections.ObservableCollections.observableList(listaContrato2);

    public ObservableList<ContratoCompraVenta> getListaObservable2() {
        return listaObservable2;
    }

    public void setListaObservable2(ObservableList<ContratoCompraVenta> listaObservable2) {
        this.listaObservable2 = listaObservable2;
    }
    private List<DocumentoPrivado> listaContrato4 = new ArrayList<DocumentoPrivado>();

    public List<DocumentoPrivado> getListaContrato4() {
        return listaContrato4;
    }

    public void setListaContrato4(List<DocumentoPrivado> listaContrato4) {
        this.listaContrato4 = listaContrato4;
    }
    private ObservableList<DocumentoPrivado> listaObservable4 = org.jdesktop.observablecollections.ObservableCollections.observableList(listaContrato4);

    public ObservableList<DocumentoPrivado> getListaObservable4() {
        return listaObservable4;
    }

    public void setListaObservable4(ObservableList<DocumentoPrivado> listaObservable4) {
        this.listaObservable4 = listaObservable4;
    }
    private List<ContratoEditable> listaContrato5 = new ArrayList<ContratoEditable>();

    public List<ContratoEditable> getListaContrato5() {
        return listaContrato5;
    }

    public void setListaContrato5(List<ContratoEditable> listaContrato5) {
        this.listaContrato5 = listaContrato5;
    }

    public ObservableList<ContratoEditable> getListaObservable5() {
        return listaObservable5;
    }

    public void setListaObservable5(ObservableList<ContratoEditable> listaObservable5) {
        this.listaObservable5 = listaObservable5;
    }
    private ObservableList<ContratoEditable> listaObservable5 = org.jdesktop.observablecollections.ObservableCollections.observableList(listaContrato5);

    public void buscar() {
        posi = 5;
        int numCon = 0;
        listaObservable.clear();
        listaObservable2.clear();
        listaObservable4.clear();
        listaObservable5.clear();
        DaoSolicitudFinanciamiento ds = new DaoSolicitudFinanciamiento();
        DaoContrato d2 = new DaoContrato();
        DaoDocumento d4 = new DaoDocumento();
        DaoContratoEditable d5 = new DaoContratoEditable();
        if (txtCedula.getText().isEmpty() == false) {
            if ((txtCedula.getText().length() == 10) == true) {
                if (Control.verificaCedulaRuc(txtCedula.getText()) == true || ds.buscarPorCedula(txtCedula.getText()).isEmpty() == false || d2.buscarPorCedula(txtCedula.getText()).isEmpty() == false || d4.buscarPorCedula(txtCedula.getText()).isEmpty() == false || d5.buscarPorCedula(txtCedula.getText()).isEmpty() == false) {
                    String ced = txtCedula.getText();
                    listaObservable.addAll(ds.buscarPorCedula(ced));
                    listaObservable2.addAll(d2.buscarPorCedula(ced));
                    listaObservable4.addAll(d4.buscarPorCedula(ced));
                    listaObservable5.addAll(d5.buscarPorCedula(ced));
                    btnMostrar.setEnabled(true);
                    numCon = listaObservable.size() + listaObservable2.size() + listaObservable4.size() + listaObservable5.size();
                    if (numCon == 1) {
                        JOptionPane.showMessageDialog(this, "Se an encontrado 1 resultado");
                    } else {
                        if (numCon == 0) {
                            JOptionPane.showMessageDialog(this, "Se an encontrado 0 resultados");
                            btnMostrar.setEnabled(false);
                        } else {
                            JOptionPane.showMessageDialog(this, "Se an encontrado " + numCon + " resultados");
                        }
                    }
                } else {
                    JOptionPane.showMessageDialog(this, "Cedula Incorrecta", "Error de Datos", JOptionPane.ERROR_MESSAGE);
                    btnMostrar.setEnabled(false);
                }
            } else {
                JOptionPane.showMessageDialog(this, "Cedula Incorrecta", "Error de Datos", JOptionPane.ERROR_MESSAGE);
                btnMostrar.setEnabled(false);
            }
        } else {
            JOptionPane.showMessageDialog(this, "Falta cédula para iniciar la búsqueda", "Error de Datos", JOptionPane.ERROR_MESSAGE);
            btnMostrar.setEnabled(false);
        }
    }
}
